package vn.sms.vsms.provider;


import java.io.IOException;
import java.util.ArrayList;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class DbHelper extends SQLiteOpenHelper {		
	
    public DbHelper(Context context) {
      super(context, DbSchema.DATABASE_NAME, null, DbSchema.DATABASE_VERSION);
     
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
    	
    	Log.i("logging",DbSchema.GroupSchema.CREATE_TABLE);
    	db.execSQL(DbSchema.GroupSchema.DROP_TABLE);
        db.execSQL(DbSchema.GroupSchema.CREATE_TABLE);         
        try {
			ArrayList<String> listStatement = DbApdater.getAssetSQL();
			if(listStatement.size()> 0)
			{
				for(String sql : listStatement)
				{
					db.execSQL(sql);
				}
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        // Read and populate OPML feeds            
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
       
    } 
}